<template>
  <div class="sjplatformAdd">
    <el-form label-width="100px">
      <el-form-item label="名称：">
        <el-input v-model="menuStore.menuModel.menuName" />
      </el-form-item>
      <el-form-item label="路径：">
        <el-input v-model="menuStore.menuModel.url" />
      </el-form-item>
      <el-form-item label="上级菜单：">
        <el-tree-select
          v-model="menuStore.menuModel.pName"
          :data="data"
          check-strictly
          :render-after-expand="false"
          @node-click="handleNodeClick"
          placeholder="请选择..."
        />
      </el-form-item>
       <el-form-item label="排序">
        <el-input v-model="menuStore.menuModel.sort" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts" setup>
import { useMenuTree } from "../../../hooks/SystemManager/Menu/useMenuTree";

const { data, menuStore, fetchData } = useMenuTree();
fetchData();

const handleNodeClick = (node) => {
  menuStore.menuModel.pid = node.id;
  menuStore.menuModel.pName = node.label;
};
</script>